package cn.hcbycloud.common.permission.config;

import cn.hcbycloud.common.jwt.service.encryptionkey.BaseGenerateJwtKeyService;
import cn.hcbycloud.common.jwt.service.jwt.JwtService;
import cn.hcbycloud.common.permission.filter.LoginUserInfoInterceptor;
import lombok.AllArgsConstructor;
import org.springframework.context.annotation.Configuration;
import org.springframework.web.servlet.config.annotation.InterceptorRegistry;
import org.springframework.web.servlet.config.annotation.WebMvcConfigurer;

/**
 * @author gaoh
 * @desc 拦截器配置类
 * @date 2022年02月06日 上午 10:04
 */
@Configuration
@AllArgsConstructor
public class InterceptorConfig implements WebMvcConfigurer {
    private JwtService jwtService;
    private BaseGenerateJwtKeyService generateJwtKeyService;
    @Override
    public void addInterceptors(InterceptorRegistry registry) {
        LoginUserInfoInterceptor loginUserInfoInterceptor = new LoginUserInfoInterceptor(jwtService,generateJwtKeyService);
        registry.addInterceptor(loginUserInfoInterceptor).addPathPatterns("/**").order(0);
    }
}